package de.szut.events;

import java.util.EventObject;

/**
 * Fires all events in an Event collection.
 * @author Marc Huisinga
 *
 * @param <T> - Type of the collection
 */
class EventCannoneer<T extends Iterable<? extends Event>> implements Event{
	private T collection;
	
	/**
	 * Initializes the collection
	 * @param collection - Collection to fire
	 */
	public EventCannoneer(T collection) {
		this.collection = collection;
	}
	
	/**
	 * Fires all events in this collection
	 * @param e - EventObject to indicate source
	 */
	public void fire(EventObject e) {
		collection.forEach(v -> v.fire(e));
	}
}
